$(function () {

  var options = {
    url: api + "/scabpm/bpm/my/definitionList",
    listType: 'bpm',
    updateUrl: '/pages/bpm/apply/edit',
    method: 'post',
    modalName: "发起申请",
    columns: [
      {
        field: 'name',
        title: '流程名称',
      },
      {
        field: 'key',
        title: '流程key'
      },
      {
        field: 'status',
        title: '状态',
        align: 'center',
        formatter: function (value, row, index) {
          return statusDict(value)
        }
      }
      , {
        field: 'version',
        title: '版本',
      }, {
        field: 'desc',
        title: '描述',
      }, {
        title: '操作',
        formatter: function (value, row, index) {
          var actions = [];
          var name = '发起申请【'+row.name+'】'
          actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.editFullBpm(\'' + row.id + '\',\'' + name + '\')"><i class="fa fa-edit"></i>启动</a> ');

          return actions.join('');
        }
      }]
  };
  $.table.init(options);
});

function statusDict(item){
  var dict = {
    'deploy': {text:'发布',color:'text-success'},
    'draft': {text:'草稿',color:'text-info'},
    'forbidden': {text:'禁用',color:'text-danger'}
  }
  return '<i class="fa '+dict[item].color+'">'+dict[item].text+'</i>'
}